package org.ens.delegation.bo;

import java.io.Serializable;
import javax.persistence.Embeddable;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * @author amine
 *
 */
@Embeddable
public class AgentEchellonPK implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Agent agent;
	private Echellon echellon;
	
	@ManyToOne
	@JoinColumn(name="code_agen")
	public Agent getAgent() {
		return agent;
	}
	
	public void setAgent(Agent agent) {
		this.agent = agent;
	}
	
	@ManyToOne
	@JoinColumn(name="code_eche")
	public Echellon getEchellon() {
		return echellon;
	}
	
	public void setEchellon(Echellon echellon) {
		this.echellon = echellon;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null || !(obj instanceof AgentEchellonPK))
			return false;
		
			AgentEchellonPK agentEchellonPK = (AgentEchellonPK) obj;
			if(agentEchellonPK.getAgent() == null || agentEchellonPK.getEchellon() == null)
				return false;
			
			return (agentEchellonPK.getAgent().equals(this.getAgent()) && agentEchellonPK.getEchellon().equals(this.getEchellon()));
	}

}
